/**
 * 
 */
package ui;

import javax.swing.*;

import exceptions.*;

import appControll.AppController;

/**
 * @author Anthares
 *
 */
public class InfoComThread extends Thread {
	private EditComEtuListPanel panel;
	private AppController app = new AppController();
	
	/**
	 * @param prog
	 */
	public InfoComThread(EditComEtuListPanel p) {
		super();
		this.panel = p;
	}

	public void run(){
		int i = 4;
		while(true){
			try{
				if(i>3){
					panel.getJaugeCom().setIndeterminate(true);
					panel.getJaugeCom().setMaximum(app.getNbrComEtu());
					i=0;
					Thread.sleep(1000);
					panel.getJaugeCom().setIndeterminate(false);
				}
				panel.getJaugeCom().setValue(panel.getComList().getRowCount());
				Thread.sleep(1000);
				i++;
			} catch (PasIdentificationException e) {
				JOptionPane.showMessageDialog(null, e, "Erreur", JOptionPane.ERROR_MESSAGE);
			} catch (DatabaseErrorException e) {
				JOptionPane.showMessageDialog(null, e, "Erreur", JOptionPane.ERROR_MESSAGE);
			} catch (InterruptedException e) {
				//TODO creer exception
			}
		}
	}
}
